package com.feihong.yw189.adapter.Kuandai;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.widget.AdapterView;

import com.feihong.yw189.R;
import com.feihong.yw189.model.Kaika.PhoneNumberModel;
import com.holenzhou.pullrecyclerview.BaseRecyclerAdapter;
import com.holenzhou.pullrecyclerview.BaseViewHolder;

import java.util.List;


/**
 * Created by PVer on 2017/12/25.
 */

public class PhoneNumberAdapter extends BaseRecyclerAdapter<PhoneNumberModel.DataBean.ListBean> {

    Activity mcontext;
    private OnItemClickListener mOnItemClickListener;


    public PhoneNumberAdapter(Context context, int layoutResId, List<PhoneNumberModel.DataBean.ListBean> data) {
        super(context, layoutResId, data);
        mcontext = (Activity) context;
    }

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        mOnItemClickListener = onItemClickListener;
    }

    @Override
    protected void convert(BaseViewHolder holder, PhoneNumberModel.DataBean.ListBean item) {
        holder.setText(R.id.tv_p, item.getPhonenum());
        holder.setText(R.id.tv_wlmq, item.getRegion_name());
        holder.setText(R.id.tv_one, item.getNum_lev_memo());
        holder.setText(R.id.tv_yctxt, item.getReal_price());
        holder.setText(R.id.tv_dxtxt, item.getMini_cost());
       // ImageView imageView = holder.getView(R.id.iv_chooseS);

        holder.setOnItemClickListener(R.id.iv_chooseS, new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                try {
                    PhoneNumberModel.DataBean.ListBean temp = getItem(position);
                    mOnItemClickListener.setOnItemCklickListener(temp.getPhonenum(), temp.getNum_lev_memo(), temp.getType_phone(), temp.getId());
                } catch (Exception ex) {
                }
                //  mOnItemClickListener.setOnItemClickListener(position);
            }
        });
//        imageView.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//
//                mOnItemClickListener.setOnItemCklickListener(item.getPhonenum(), item.getNum_lev_memo(), item.getType_phone(), item.getId());
//            }
//        });

    }

    public interface OnItemClickListener {
        /**
         * @param phone
         * @param num_lev_memo
         * @param type_phone
         * @param phontID
         */
        void setOnItemCklickListener(String phone, String num_lev_memo, String type_phone, String phontID);

        void setOnItemClickListener(int position);


    }

}
